<?php
/**
 * @author jiangyong<jiangyong.go@qq.com>
 * @date   2025/6/17 20:17
 */

namespace App\Lib;

class Base
{
    public function __construct($config = [])
    {
        if (!empty($config)) {
            Obj::configure($this, $config);
        }
        $this->init();
    }

    public function init()
    {

    }

    public function __get($name)
    {
        $getter = 'get' . $name;
        if (method_exists($this, $getter)) {
            // read property, e.g. getName()
            return $this->$getter();
        }
    }

    public function __set($name, $value)
    {
        $setter = 'set' . $name;
        if (method_exists($this, $setter)) {
            // set property
            $this->$setter($value);
            return;
        }
        $this->$name = $value;
    }
}
